﻿namespace Example
{
    using Microsoft.Practices.ServiceLocation;

    using Moq;

    using Xunit;

    public sealed class DisplayFacts
    {
        [Fact]
        public void prop_Message()
        {
            try
            {
                var expected = new Mock<IMessage>().Object;

                var mock = new Mock<IServiceLocator>();
                mock.Setup(e => e.GetInstance<IMessage>()).Returns(expected).Verifiable();
                ServiceLocator.SetLocatorProvider(() => mock.Object);

                var actual = new Display().Message;

                Assert.Same(expected, actual);

                mock.VerifyAll();
            }
            finally
            {
                ServiceLocator.SetLocatorProvider(null);
            }
        }
    }
}